﻿function reg_check(input){
    input = $(input);
    var id = input.attr("id");
    switch(id)
    {
        case "txtPW":
            if(input.val().length < 4){
	            $("#msgPW")[0].className = "regtly_error";
	            $("#msgPW").text("请输入6-20密码！");
	             return false;
	        }else{
	            $("#msgPW")[0].className = "regtly_ok";
	            $("#msgPW").text("");
	        }
            break;
        case "txtNewPW":
            if(input.val().length < 4){
	            $("#msgNewPW")[0].className = "regtly_error";
	            $("#msgNewPW").text("请输入6-20密码！");
	             return false;
	        }else{
	            $("#msgNewPW")[0].className = "regtly_ok";
	            $("#msgNewPW").text("");
	        }
            break;
        case "txtReNewPW":
	        if(input.val().length < 4){
	            $("#msgReNewPW")[0].className = "regtly_error";
	            $("#msgReNewPW").text("请输入确认密码！");
	             return false;
	        }else if(input.val() != $("#txtNewPW").val()){
	            $("#msgReNewPW")[0].className = "regtly_error";
	            $("#msgReNewPW").text("两次输入密码不一致！");
	             return false;
	        }else{
	            $("#msgReNewPW")[0].className = "regtly_ok";
	            $("#msgReNewPW").text("");			     
	        }
	        break;
    }
    return true;
}

function focus_input(input){
    input = $(input);
    var id = input.attr("id");
    switch(id)
    {
        case "txtPW":
            $("#msgPW")[0].className = "regtly";
            $("#msgPW").text("6-20字符,数字或字母，区分大小写。");
            break;
        case "txtNewPW":
            $("#msgNewPW")[0].className = "regtly";
            $("#msgNewPW").text("6-20字符,数字或字母，区分大小写。");
            break;
        case "txtReNewPW":			
            $("#msgReNewPW")[0].className = "regtly";
            $("#msgReNewPW").text("请再次输入您的密码。");
	        break;
    }
}

function check_submit()
{
    var result = true;    
    (!reg_check($("#txtPW")[0]))?(result=false):"";
    (!reg_check($("#txtNewPW")[0]))?(result=false):"";
    (!reg_check($("#txtReNewPW")[0]))?(result=false):"";
    ($(".regtly_error").length > 0)?(result=false):"";
    
    return result;
}
